<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>后台登录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/login/css/login.css" >
</head>
<body>

<div class="login-bg">
    <div class="login-box">
        <h1 class="login-title">
            <center>内部管理系统</center>
        </h1>
        <form class="layui-form" action="{{route('auth.login')}}"  method="post">
            {{csrf_field()}}
            <div class="layui-form-item field-loginform-username required">
                <label class="layui-form-label" for="loginform-username">帐号</label>
                <div class="layui-input-block">
                    <input type="text" name="name" value="" class="layui-input" lay-verify="required" placeholder="请输入帐号">
                </div>
            </div>
            <div class="layui-form-item field-loginform-password required">
                <label class="layui-form-label" for="loginform-password">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" class="layui-input" lay-verify="required" placeholder="请输入密码">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label"></label>
                <div class="layui-input-block">
                    <button lay-submit lay-filter="go" type="button" class="layui-btn" data-url="/">登 入</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).use(['layer', 'form', 'element'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        form.on('submit(go)', function (data) {
            var load = layer.load();
            var url = $(data.elem).data('url')
            $.post(data.form.action, data.field, function (res) {
                layer.close(load);
                var code = res.code
                layer.msg(res.msg, {time: 2000, icon: code == 0 ? 1 : 2}, function () {
                    if (code === 0) {
                        if(url != undefined){
                            location.href = url
                        }
                    }
                });
            }, 'json');
            return false;
        });
    })
</script>
</body>
</html>
